package map.abstractor.uimodel;



import map.tools.interactions.WidgetBehaviorTable;
import uimigration.UIModel.UIModel;
import uimigration.UIModel.UIModelFactory;
import uimigration.WidgetsModel.APIModel;
import uimigration.xmluimodel.Object;

public class ModelXML2UIModel {
	
	//Input parameters
	private APIModel apimodel=null;
	private Object xmlmodel=null;
	private WidgetBehaviorTable tableBehavior=null;
	
	//Output 
	private UIModel uimodel=null;

	public ModelXML2UIModel(Object xlmModel, APIModel api, WidgetBehaviorTable table ){
		setXmlmodel(xlmModel);
		setApimodel(api);
		setTableBehavior(table);
	}
	
	public UIModel abstractUIModel(){

		uimodel= UIModelFactory.eINSTANCE.createUIModel();
		uimodel.setName("Appli_"+apimodel.getApiName());
		AbstractXMLObject xml= new AbstractXMLObject();
		for(Object o:xmlmodel.getChilds()){
			uimigration.UIModel.UIElement element=xml.process(o, apimodel, tableBehavior, null);
			if(element!=null)
				uimodel.getContains().add(element);
		}
		return uimodel;
	}

	public void setApimodel(APIModel apimodel) {
		this.apimodel = apimodel;
	}

	public APIModel getApimodel() {
		return apimodel;
	}

	public void setXmlmodel(Object xmlmodel) {
		this.xmlmodel = xmlmodel;
	}

	public Object getXmlmodel() {
		return xmlmodel;
	}

	public void setTableBehavior(WidgetBehaviorTable tableBehavior) {
		this.tableBehavior = tableBehavior;
	}

	public WidgetBehaviorTable getTableBehavior() {
		return tableBehavior;
	}

}
